package com.lezhi.socialgram.api.sys;

import com.lezhi.socialgram.util.ValidUtils;
import com.lezhi.socialgram.model.sys.SignUpUser;
import com.lezhi.socialgram.service.sys.SignUpService;
import com.lezhi.socialgram.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * Created by daizhen on 2017/3/23.
 * 注册 api 注册、查看手机号是否可以注册、修改绑定手机号
 */
@RestController
public class SignUpApi {

    private static final Logger logger = LoggerFactory.getLogger(SignUpApi.class);

    @Autowired
    SignUpService signUpService;

    @PostMapping("/signUp")
    public Result signUp(@RequestBody @Valid SignUpUser signUpUser,
                         BindingResult bindingResult) {
        ValidUtils.valid(logger, bindingResult);
        return signUpService.signUp(signUpUser);
    }

    @GetMapping("/checkTelNum/{telNum}")
    public Result checkTelNumSignIn(@PathVariable("telNum") String telNum) {
        return signUpService.checkTelNumSignUp(telNum);
    }

}
